<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

use Webman\Route;

Route::fallback(function () {
    throw new \Tinywan\ExceptionHandler\Exception\RouteNotFoundException();
});

Route::group('/api/account-book', function () {
    Route::post('/create', [app\controller\AccountBookController::class, 'create']);
    Route::get('/list', [app\controller\AccountBookController::class, 'list']);
    Route::post('/add-member', [app\controller\AccountBookController::class, 'addMember']);
    Route::post('/remove-member', [app\controller\AccountBookController::class, 'removeMember']);
    Route::get('/members', [app\controller\AccountBookController::class, 'members']);
    Route::get('/detail', [app\controller\AccountBookController::class, 'detail']);
    Route::post('/update', [app\controller\AccountBookController::class, 'update']);
    Route::post('/delete', [app\controller\AccountBookController::class, 'delete']);
});

Route::group('/api/category', function () {
    Route::post('/create', [app\controller\CategoryController::class, 'create']);
    Route::get('/list', [app\controller\CategoryController::class, 'list']);
    Route::post('/update', [app\controller\CategoryController::class, 'update']);
    Route::post('/delete', [app\controller\CategoryController::class, 'delete']);
    Route::post('/sort', [app\controller\CategoryController::class, 'sort']);
});

Route::group('/api/transaction', function () {
    Route::post('/create', [app\controller\TransactionController::class, 'create']);
    Route::get('/list', [app\controller\TransactionController::class, 'list']);
    Route::post('/update', [app\controller\TransactionController::class, 'update']);
    Route::post('/delete', [app\controller\TransactionController::class, 'delete']);
    Route::get('/detail', [app\controller\TransactionController::class, 'detail']);
});

Route::group('/api/share', function () {
    Route::post('/create', [app\controller\ShareController::class, 'create']);
    Route::post('/accept', [app\controller\ShareController::class, 'accept']);
    Route::get('/info', [app\controller\ShareController::class, 'info']);
});

// 用户相关路由
Route::group('/api/user', function () {
    Route::post('/login', [app\controller\UserController::class, 'login']);
    Route::post('/update-info', [app\controller\UserController::class, 'updateUserInfo']);
    Route::post('/set-default-book', [app\controller\UserController::class, 'setDefaultBook']);
    Route::get('/info', [app\controller\UserController::class, 'info']);
});